from dataclasses import dataclass
from typing import Optional, final


@final
@dataclass
class ValidTaskData(object):
    """Used to represent valid data that we can use to create a task."""

    title: str
    description: str
    is_done: bool


def validate(
    title: Optional[str],
    description: Optional[str],
    is_done: Optional[bool],
) -> Optional[ValidTaskData]:
    """Validates incomming data and decides if we can save it as a post."""
    if not title or not description or is_done is None:
        return None
    return ValidTaskData(title=title, description=description, is_done=is_done)
